######################################################################
# Time-stamp: <04/03/12 11:13:18 ostolop>
#
# Dispatcher routines to validate EPC queries
######################################################################
package EP::Common::Query::QueryValidator;
use strict;

use EP::EPC::Interface::Validator::User_Management;
use EP::EPC::Interface::Validator::Data_Upload;
use EP::EPC::Interface::Validator::Data_Selection;
use EP::EPC::Interface::Validator::Hierarchical_Clustering;
use EP::EPC::Interface::Validator::Between_Group_Analysis;
use EP::EPC::Interface::Validator::Clustering_Comparison;

=head1 NAME

EP_UI_XML::QueryValidator

=head1 SYNOPSIS

=head1 DESCRIPTION

=head1 METHODS

=over

=back

=cut

sub new {
  my $proto = shift;
  my ( $query ) = @_;

  my $class = ref($proto) || $proto;
  my $self  = {};
  bless $self, $class;
  $self->initialize ( $query );
  return $self;
}

sub initialize {
  my $self = shift;
  my ( $query ) = @_;

  $self->{0}  = EP::EPC::Interface::Validator::User_Management->new ( $query );
  $self->{1}  = EP::EPC::Interface::Validator::Data_Upload->new ( $query );
  $self->{2}  = EP::EPC::Interface::Validator::Data_Selection->new ( $query );
#  $self->{3}  = EP::EPC::Interface::Validator::Hierarchical_Clustering->new ( $query );
#  $self->{4}  = EP::EPC::Interface::Validator::Hierarchical_Clustering->new ( $query );
#  $self->{13} = EP::EPC::Interface::Validator::Hierarchical_Clustering->new ( $query );
#  $self->{12} = EP::EPC::Interface::Validator::Hierarchical_Clustering->new ( $query );

  $self->{6} = EP::EPC::Interface::Validator::Between_Group_Analysis->new ( $query );
#  $self->{7} = EP::EPC::Interface::Validator::Hierarchical_Clustering->new ( $query );

#  $self->{9} = EP::EPC::Interface::Validator::Clustering_Comparison->new();

  return;
}

sub validate {
  my $self = shift;
  my $compid = shift;
  my $epc = ref ( $self->{$compid} );
  if ( not $epc eq "") {
    return $self->{$compid}->validate ( @_ );
  } else {
    print STDERR "[EPC Query Validator] No validation component loaded for EPC, id $compid! Validating by default!\n";
    return ""; # still mark as valid...
  }
}

1;
